package com.qf.fmall2204.orders.controller;

import cn.hutool.core.util.XmlUtil;
import com.qf.fmall2204.constants.Constants;
import com.qf.fmall2204.orders.entity.Orders;
import com.qf.fmall2204.orders.service.IOrdersService;
import com.qf.fmall2204.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 订单  前端控制器
 * </p>
 *
 * @author dong
 * @since 2023-04-25
 */
@CrossOrigin
@RestController
@RequestMapping("/order")
public class OrdersController {

    @Autowired
    IOrdersService ordersService;

    @GetMapping("/status/{oid}")
    public ResultVo status(@PathVariable("oid") String oid) throws Exception {

        String status =  ordersService.status(oid);

        return new ResultVo(Constants.SUCCESS_CODE, "success", status);

    }

    @PostMapping("/add")
    public ResultVo add(Integer[] cids,@RequestBody Orders orders) throws Exception {

        Map<String,Object> result = ordersService.add(cids,orders);

        return new ResultVo(Constants.SUCCESS_CODE, "success", result);

    }

}
